This is an interactive notebook. You can run it locally or use the links below:
๐ Prerequisites
Before you can begin tracing in Weave, complete the following prerequisites.- Install the W&B Weave SDK and log in with your API key.
- Install the OpenAI SDK and log in with your API key.
- Initialize your W&B project.
๐ Run your first trace
The following code sample shows how to capture and visualize a trace in Weave using the@weave.op
decorator. It defines a function called extract_fruit
that sends a prompt to OpenAIโs GPT-4o to extract structured data (fruit, color, and flavor) from a sentence. By decorating the function with @weave.op
, Weave automatically tracks the function execution, including inputs, outputs, and intermediate steps. When the function is called with a sample sentence, the full trace is saved and viewable in the Weave UI.
๐ Looking for more examples?
- Check out the Quickstart guide.
- Learn more about advanced tracing topics.
- Learn more about tracing in Weave